package com.china.produce.pojo;

import com.china.produce.system.util.ServerLongPollingUtil;
import lombok.extern.slf4j.Slf4j;
import java.util.Iterator;

/**
 * @ClassName
 * @Author niujie
 * @Version
 * @Description
 * @CreateTime 2022/12/28
 */
@Slf4j
public class DataChangeTask implements Runnable{

    final String groupKey;

    public DataChangeTask(String groupKey) {
        this.groupKey = groupKey;
    }

    @Override
    public void run() {
        Iterator<ClientLongPolling> iterator = ServerLongPollingUtil.allSubs.iterator();
        while (iterator.hasNext()) {
            ClientLongPolling clientSub = iterator.next();
            if (clientSub.groupKey.equalsIgnoreCase(groupKey)) {
                iterator.remove();
                clientSub.sendResponse(groupKey);
            }
        }
    }
}
